<?php
	function sec2time($ss) {
		$s = $ss%60;
		$m = floor(($ss%3600)/60);
		$h = floor(($ss%86400)/3600);
		$d = floor(($ss%2592000)/86400);
		
		return $d ."d " . $h . "h " . $m . "m " . $s . "s";
	}
?>

<div id='bgDiv' style="width: 100%; height: 100%; background: #fff; font-size: 200%; padding: 20px;">
	<h2>System Details</h2>

	UPTIME:
	<div style='float: right; margin-right: 40px;'>
		<?php
			$uptimeReturn = shell_exec("cat /proc/uptime");
			$uptimeTok = strtok($uptimeReturn, " ");
			echo sec2time($uptimeTok);
		?>
	</div><br>

	CPU:
	<div style='float: right; margin-right: 40px;'>
		<?php
			$cpuInfoReturn = shell_exec("cat /proc/cpuinfo");
			
			$cpuInfo1 = strpos($cpuInfoReturn, "model name")+13;
			$cpuInfo2 = strpos($cpuInfoReturn, "stepping");
			$cpuInfo = substr($cpuInfoReturn, $cpuInfo1, ($cpuInfo2 - $cpuInfo1));
			echo $cpuInfo;
		?>
	</div><br>

	RAM:
	<div style='float: right; margin-right: 40px;'>
		<?php
			$ramInfoReturn = shell_exec("cat /proc/meminfo");

			$ramInfo1 = strpos($ramInfoReturn, "MemTotal:") + 10;
			$ramInfo2 = strpos($ramInfoReturn, "kB", $ramInfo1);
			$ramTotal = substr($ramInfoReturn, $ramInfo1, ($ramInfo2 - $ramInfo1));
			
			$ramInfo3 = strpos($ramInfoReturn, "MemAvailable:") + 13;
			$ramInfo4 = strpos($ramInfoReturn, "kB", $ramInfo3);
			$ramFree = substr($ramInfoReturn, $ramInfo3, ($ramInfo4 - $ramInfo3));

			echo round((int)$ramFree/1024/1024, 2) . " gb" . " [" . round((int)$ramTotal/1024/1024, 2) . " gb]<br>";
			
		?>
	</div><br>

	HDD:
	<div style='float: right; margin-right: 40px;'>
		<?php
			$hddInfoReturn = shell_exec("df -h /dev/sda1");
			$hddInfoName = substr($hddInfoReturn, strpos($hddInfoReturn, "Mounted on")+10, 10);
			$hddInfoSize = substr($hddInfoReturn, strpos($hddInfoReturn, "Mounted on")+20, 13);
//			$hddInfoUsed = strtok(" ");
//			$hddInfoAvail = strtok(" ");
			
			echo $hddInfoName."<br>";
			echo $hddInfoSize."<br>";
		?>
	</div><br>

	Network: <input type='text' size='25' value='http://localhost:8080/osm/' class='txtMapServer'><br>

	Other:
	<div style='float: right; margin-right: 40px;'>
		<div class="onoffswitch">
			<input type="checkbox" name="onoffswitch3" class="onoffswitch-checkbox" id="myonoffswitch3" checked>
			<label class="onoffswitch-label" for="myonoffswitch3">
				<span class="onoffswitch-inner"></span>
				<span class="onoffswitch-switch"></span>
			</label>
		</div>
	</div><br>



</div>
